package order.api;

import order.dao.OrderInfo;
import order.dao.ProductInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * value 是服务的名字，用来服务发现
 * path 是当前请求的前缀
 */
@FeignClient(value = "product-server", path = "/product")
public interface ProductApi {
    @RequestMapping("/{productId}")
    ProductInfo getProductInfo(@PathVariable("productId") Long productId);

    @RequestMapping("o1")
    void o1(@RequestParam("id") Long id,@RequestParam("name") String name);

    /**
     * url 拼接
     * URL: http://[240e:398:5da8:c470:f3ee:bfed:5840:58bc]:8081/product/o2?deleteFlag=0&productId=1001&createTime=Fri%20Jun%2027%2016%3A23%3A58%20CST%202025&price=99&num=1&updateTime=Fri%20Jun%2027%2016%3A23%3A58%20CST%202025&id=1&userId=2001
     * 2025-07-01T17:59:09.434+08:00
     * @SpringQueryMap 这是拼接到url中
     * 它的核心作用是将一个POJO对象自动转换为URL查询字符串
     * ?deleteFlag=0&productId=1001 这样
     */
    @RequestMapping("o2")
    void o2(@SpringQueryMap OrderInfo orderInfo);

    /**
     * 这是给放到body中
     */
    @RequestMapping("o3")
    void o3(@RequestBody OrderInfo orderInfo);
}
